import {
  legacy_createStore,
  combineReducers,
  compose,
  applyMiddleware,
} from 'redux'
import { thunk } from 'redux-thunk'

import NumStatusReducer from './NumStatus/reducer'
import ArrStatusReducer from './ArrStatus/reducer'

// 组合各个模块的reducer
const reducers = combineReducers({
  NumStatusReducer,
  ArrStatusReducer,
})

// 创建数据仓库
// const store = legacy_createStore(
//   reducers,
//   window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
// )

let composeEnhancers =
  typeof window === 'object' &&
  (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
    ? (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
    : compose
const store = legacy_createStore(
  reducers,
  composeEnhancers(applyMiddleware(thunk))
)

export default store
